﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using cmsservice.BLL;
using cmsservice.Common.Memcached;
using cmsservice.DAL;

/// <summary>
///CommService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class CommService : System.Web.Services.WebService {

    public CommService () {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod(Description="mini添加统计")]
    public void AddCount(string ip )
    {
        CommBLL cBLL = new CommBLL();
        cBLL.AddMiniCount(ip);
    }

    [WebMethod(Description = "获取炒股大赛行情 ")]
    public string GetStockHq(string stock)
    {
        StockMemcachedTools service = new StockMemcachedTools();
        var data= service.Get<byte[]>(stock);
        string str= System.Text.Encoding.GetEncoding("gb2312").GetString(data);
        str = str.TrimEnd('\0');
        return str;
    }

    [WebMethod(Description = "反弹模型行情 ")]
    public string GetFTStockHq(string stock)
    {
        FTStockMemcachedTools service = new FTStockMemcachedTools();
        var data = service.Get<byte[]>(stock);
        string str = System.Text.Encoding.GetEncoding("gb2312").GetString(data);
        str = str.TrimEnd('\0');
        return str;
    }

    [WebMethod(Description="数据库加密")]
    public byte[] GetJmMobile(string mobile)
    {
        Tools tool = new Tools();
        tool.AddSqlParameter("mobile", System.Data.SqlDbType.VarChar, 50, mobile);
        string sql = "select master.dbo.fn_encrypt(@mobile)";
        var obj = SqlHelper.ExecuteScalar(DBConn.TemporaryDB, System.Data.CommandType.Text, sql, tool.GetSqlParameters());
        return (byte[])obj;
    }

}
